<template>
  <div style="text-align: left;" v-if="show">
    <a-row type="flex">
      <a-col :span="6" :order="4" class="item">
        <span>订单号: </span>{{ data.purchaseNo }}
      </a-col>
      <a-col :span="6" class="item">
        <span>单据日期: </span>{{ data.receiptsTime == null ? '无' : data.receiptsTime }}
      </a-col>
      <a-col :span="6" class="item">
        <span>交货日期: </span>{{ data.deliveryTime == null ? '无' : data.deliveryTime}}
      </a-col>
      <a-col :span="6" class="item">
        <span>采购员人员: </span>{{ data.purchasePeople }}
      </a-col>
    </a-row>
    <a-row>
      <a-col :span="6" class="item">
        <span>创建人: </span>{{ data.createBy }}
      </a-col>
      <a-col :span="6" class="item">
        <span>创建日期: </span>{{ data.createTime }}
      </a-col>
      <a-col :span="6" class="item">
        <span>仓库: </span>{{ data.depositoryName }}
      </a-col>
      <a-col :span="6" class="item">
        <span>供应商: </span>{{ data.supplierName }}
      </a-col>
    </a-row>
    <a-table
      :columns="columns"
      :data-source="data.materials"
      bordered />
    <a-row>
      <a-col :span="6" class="item">
        <span>合计: </span>{{ this.data.purchasePrice == null ? 0 : this.data.purchasePrice }}
      </a-col>
      <a-col :span="6" class="item">
        <span>优惠率: </span>{{ this.data.discountedRate == null ? 0 : this.data.discountedRate }}%
      </a-col>
      <a-col :span="6" class="item">
        <span>优惠金额: </span>{{ this.data.discountedMoney == null ? 0 : this.data.discountedMoney }}
      </a-col>
      <a-col :span="6" class="item">
        <span>优惠后总计金额: </span>{{ this.data.discountedPurchasePrice == null ? 0 : this.data.discountedPurchasePrice }}
      </a-col>
    </a-row>
  </div>
</template>

<script>
  import { getAction } from '@/api/manage'
  export default {
    name: "PurchaseOrder",
    data() {
      return {
        data: '',
        title:'',
        show: false,
        url: {
          getPurchaseOrderById: '/ghSupplychainPurchaseOrder/getById',
        },
        columns: [
          {
            title: '名称',
            dataIndex: 'materialName',
            scopedSlots: { customRender: 'materialName' },
          },{
            title: '型号',
            dataIndex: 'modelNumber',
          },{
            title: '规格',
            dataIndex: 'specifications',
          },{
            title: '品牌',
            dataIndex: 'brand',
          },{
            title: '市场价格',
            dataIndex: 'marketPrice',
          },{
            title: '采购数量',
            dataIndex: 'purchaseNum',
          },{
            title: '单价',
            dataIndex: 'unitPrice',
          },{
            title: '折扣率',
            dataIndex: 'discountedRate'
          },{
            title: '折扣额',
            dataIndex: 'discountedMoney'
          },{
            title: '折后单价',
            dataIndex: 'discountedPurchasePrice'
          },{
            title: '小计金额',
            dataIndex: 'subtotal'
          },{
            title: '备注',
            dataIndex: 'remark',
          }
        ]
      }
    },
    methods: {
      initData(params) {
        getAction(this.url.getPurchaseOrderById, params)
        .then(res => {
          if (res.success) {
            this.data = res.result;
          }
        });
      }
    }
  }
</script>
<style>
  .item {
    padding: 15px
  }
</style>